<?php 
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\Modal;

// 创建a标签
echo Html::a('创建','#',[
    'id'=>'create',
    'data-toggle'=>'modal',
    'data-target'=>'#create-modal',
    'class'=>'btn btn-success',
]);

// 创建表单
Modal::begin([
    'id'=>'create-modal',
    'header'=>'<h4 class="modal-title">创建</h4>',
    'footer'=>'<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>'
]);
Modal::end();

$requestUrl = Url::toRoute("names");
$js = <<<JS
 $(document).on("click","#create",function(){
     $.get("{$requestUrl}",{},function(data){
        $("#create-modal .modal-body").html(data);
     })
 })
JS;

$this->registerJs($js);